using System;
using System.Collections.Generic;

namespace Battle.TimelineLog
{
    public class SysDataCls<T>
    {
        public string primaryKey;
        public string[] langKeys;
        public List<T> list;
    }
    /// <summary>
    /// 静态数据的hash列表
    /// </summary>
    public class SysHashList<T> : HashList<T> where T : ISysMainKey
    {
        public string Name { get; set; }
        public bool HasInit { get; private set; }
        public SysHashList() { }
        public void ParserData(string content)
        {
            var data = LitJson.JsonMapper.ToObject<SysDataCls<T>>(content);
            m_list = data.list;
            for (int i = 0; i < m_list.Count; i++)
            {
                T item = m_list[i];
                string mainKey = item.MainKey;
                if (mainKey != string.Empty && !m_dic.ContainsKey(mainKey))
                {
                    m_dic.Add(mainKey, item);
                }
                else
                {
                    Console.WriteLine(" ===>> {0}表主键{1}重复或为空", Name, mainKey);
                }
            }
            HasInit = true;
        }

    }
}